package com.cooldatasoft.web.cms.common;

import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.cooldatasoft.app.WOCApplication;
import com.cooldatasoft.app.WOCSession;
import com.cooldatasoft.data.WorkExpProperty;
import com.cooldatasoft.web.cms.workExpProperty.WorkExpPropertyListPage;
import com.cooldatasoft.web.cms.workExpProperty.WorkExpPropertyViewPage;

public class WorkExpPropertyEditPanel extends Panel {

	public WorkExpPropertyEditPanel(String id, IModel model, final FeedbackPanel feedbackPanel) {
		super(id, model);
		Link editLink = new Link("edit") {
			public void onClick() {
				Integer entityId = ((WorkExpProperty)getParent().getModelObject()).getId();
				
				setResponsePage(new WorkExpPropertyViewPage(entityId));
			}
		};
		add(editLink);
		
		Link deleteLink=new Link("delete") {
			public void onClick() {				
				//Get selected object id
				Integer entityId = ((WorkExpProperty)getParent().getModelObject()).getId();
				WOCApplication.get().getWorkServiceProxy().deleteWorkExpPropertyById(entityId,((WOCSession)WOCSession.get()).getUser());
				setResponsePage(WorkExpPropertyListPage.class);
			}
		};
		deleteLink.add( new SimpleAttributeModifier("onclick", "return confirm('Do you want to delete this record?');"));
		add(deleteLink);
	}
	


}
